// var config = require("../../config.js");
import http from '../../util/request.js';
import alert from '../../util/alert.js';
Page({
  data:{
    page:2,
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
	var that = this;
	//that.setData({products:config.products});
  that.load();
  },
  load() {
    http.get('api', { r: 'home.Productlist' }).then(data => {
      this.setData({ products: data });
    });
  },
  getMore: function (e) {
    var that = this;
    var page = that.data.page;
    http.get('api',{
      r: 'home.Productlist',
      page: page
    }).then(data => {
      if(data==''){
        alert('没有了','');
      }
      this.setData({ 
        page: page + 1,
        products: that.data.products.concat(data)
        });
    });
  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  }
})